package com.cy.pj.sys.dao;

import com.cy.pj.sys.pojo.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface AdminDao {
    /**
     * 根据账户,姓名,email关键字搜索,进行查询
     * @param keyword
     * @return
     */
    List<Admin> selectAdminByKeyword(String keyword);
    /**
     * 根据id删除多条数据
     */

    int deleteAdminById(Integer[] ids);

    /**
     *新增用户
     * @param admin
     * @return
     */
    @Insert("insert into t_admin (id,login_acct,user_pswd,user_name,email,create_time) values(null,#{loginAcct},#{userPswd},#{userName},#{email},#{createTime})")
    int insertAdmin(Admin admin);

    @Update("update t_admin set login_acct=#{loginAcct},user_pswd=#{userPswd},user_name=#{userName},email=#{email} where id=#{id}")
    int updateAdminById(Admin admin);

    /**
     * 根据ID查询用户做回显数据
     * @param id
     * @return
     */

    Admin findAdminById(Integer id);

    @Select("select * from t_admin where login_acct=#{username}")
    Admin findUserByUserName(String username);
}
